<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<style>
    .clickMe_form {
        margin-left: 770px;
        cursor: pointer;
        color: #1C98FF;
    }
</style>
<form:form commandName="task" cssClass="form-horizontal" role="form" onsubmit="return false;">
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="taskName">任务名称</label>
        <div class="col-sm-5">
            <input type="text" name="taskName" id="taskName" placeholder="任务名称" readonly="readonly"
                   value="<c:out value="${task.taskName}"/>"
                   class="form-control " title="<c:out value="${task.taskName}"/>">
        </div>
        <label class="col-sm-1 control-label no-padding-right" for="projectName">项目名称</label>
        <div class="col-sm-5">
            <input type="text" name="projectName" id="projectName" placeholder="项目名称" readonly="readonly"
                   value="<c:out value="${task.projectName}"/>"
                   class="form-control " title="<c:out value="${task.projectName}"/>">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="taskContent">任务内容</label>
        <div class="col-sm-11">
            <textarea rows="2" id="taskContent" name="taskContent" readonly="readonly" placeholder="任务内容"
                      class="form-control ">${task.taskContent}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="selectTime">选择日期</label>
        <div class="col-sm-5">
            <input id="selectTime" placeholder="点击选择时间" type="text" name="datatime" class="form-control"
                   required/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="taskContent">完成情况</label>
        <div class="col-sm-11">
			<textarea rows="4" id="record" name="record" placeholder="点击填写"
                      class="form-control" required/>
        </div>
    </div>

    <%--<input type="text" value="请输入要查找的关键字" onfocus="if(value=='请输入要查找的关键字')value=''" onblur="if(!value)value='请输入要查找的关键字'" name="keyword" >--%>


    <div class="form-group">

        <label class="col-sm-1 control-label no-padding-right" for="resp-Result">节点情况</label>

        <div class="col-sm-5">
            <input type="text" name="resp-Result" id="resp-Result" readonly="readonly"
                   class="form-control ">
        </div>


    </div>
    <%--<div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="taskContent">反馈信息</label>
        <div class="col-sm-11">
			<textarea rows="4" id="feedbackInfo" name="feedbackInfo" placeholder="点击填写"
                      class="form-control" required/>
        </div>
    </div>--%>

    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right">佐证材料</label>
        <input class="col-sm-5" type="file" id="fileupload" name="files"/>
        <button class="col-sm-4 btn btn-large btn-primary" id="btn-upload">上传</button>
        <input type="text" name="taxproof" id="taxproof_proof"
               class="form-control " style="display: none"/>
    </div>
    <hr width="100%;height:2px;">
    <h4 class="clickMe_form">历史记录∨</h4>
    <div class="open-sibling" hidden>
        <hr width="100%;height:2px;">
        <c:if test="${not empty listRecords}">
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right formsHead"
                       for="taskContent">责任单位反馈情况:</label>
            </div>
        </c:if>
        <c:forEach items="${listRecords}" var="listRecords">
            <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right">反馈时间</label>
                <div class="col-sm-2">
                    <input type="text" value="${listRecords.datatime}"
                           placeholder="" readonly="readonly" class="form-control ">
                </div>
                <div class="col-sm-3">
                    <button class="btn btn-sm btn-primary downloadFile" data-id="${listRecords.taxproof}"
                            style="width: 100%;">
                        下载附件
                    </button>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right">完成情况</label>
                <div class="col-sm-11">
                    <textarea rows="3" class="form-control" readonly="readonly">${listRecords.record}</textarea>
                </div>
            </div>
            <hr width="100%;height:2px;">
        </c:forEach>
        <c:if test="${not empty supervisionLogs}">
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right formsHead"
                       for="taskContent">督查组反馈情况:&nbsp;&nbsp;&nbsp;</label>
            </div>
        </c:if>
        <c:forEach items="${supervisionLogs}" var="logs">
            <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right">督查日期</label>
                <div class="col-sm-2">
                    <input type="text" value="${logs.datatime}" readonly="readonly"
                           placeholder="请输入时间" class="form-control ">
                </div>

                <label class="col-sm-1 control-label no-padding-right">督查方式</label>
                <div class="col-sm-3">
                    <input type="text" value="${logs.methonName}" readonly="readonly"
                           placeholder="请输入项目进展" class="form-control">
                </div>

                <div class="col-sm-3">
                    <button class="btn btn-sm btn-primary downloadFile" data-id="${logs.taxproof}" style="width: 100%;">
                        下载附件
                    </button>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right">填写日期</label>
                <div class="col-sm-2">
                    <input type="text" value="${logs.createDate}" readonly="readonly" class="form-control">
                </div>

                    <%--<label class="col-sm-1 control-label no-padding-right">任务时限</label>
                    <div class="col-sm-2">
                        <c:choose>
                            <c:when test="${not empty logs.deadline}">
                                <input type="number" readonly="readonly" value="${logs.deadline}" maxlength="2" min="1" max="99"
                                       class="form-control ">
                            </c:when>
                            <c:otherwise>
                                <input type="number" readonly="readonly" placeholder="无" value="${logs.deadline}" maxlength="2"
                                       min="1" max="99" class="form-control ">
                            </c:otherwise>
                        </c:choose>
                    </div>--%>
                <label class="col-sm-1 control-label no-padding-right">督查要求</label>
                <div class="col-sm-8">
                    <textarea rows="1" class="form-control" readonly="readonly">${logs.supervisionAsk}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label no-padding-right">督查记录</label>
                <div class="col-sm-11">
                    <textarea rows="2" class="form-control" readonly="readonly">${logs.record}</textarea>
                </div>

            </div>
            <hr width="100%;height:2px;">

        </c:forEach>
    </div>
    <form:hidden path="sysId"/>
</form:form>
<div class="row" style="margin-left: 2px;">
    * 以上按住如此标志：<img src="/assets/web/img/zzc.png" alt="提示"/>可拖动调整相应输入框大小
</div>
<script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>
<script>
    //上传文件请求
    $("#btn-upload").click(function () {
        var fileval = $("#fileupload").val();
        if (fileval == null || fileval == "") {
            alert("未选择任何文件");
            return;
        }
        $(".shade").fadeIn(100);
        $(".warning").fadeIn(100);
        $('.la-square-jelly-box').show();
        showShade();
        //警告框自定义内容
        $('.warning>.title>em').html('加载中……');
        $.ajaxFileUpload({
            type: "post",
            fileElementId: "fileupload",
            secureuri: false,
            dataType: 'text',
            url: "/communal/uploadBatch",
            // data:fileinfo,
            async: false,
            success: function (data) {
                var data = JSON.parse(data);
                console.log(data);
                var val = data.data.sysid;
                console.log(val);
                $("#taxproof_proof").attr("value", val);
                if (data.code === "200") {
                    $('.warning>.title>em').html('上传成功');
                } else {
                    $('.warning>.title>em').html('上传失败');
                }
            },
            error: function (data) {
                /*$("#dialog").dialog("close");*/

                alert("佐证材料上传失败 ！！请联系管理员");
            }

        });

    });

    /**
     * 下载
     */
    $(".downloadFile").click(function () {
        var id = $(this).data("id");
        var url = "/communal/download/" + id;
        window.open(url);
    });

    //显示隐藏
    $(".clickMe_form").click(function () {
        if ($(this).text() === "历史记录∨") {
            $(this).next(".open-sibling").show(500);
            $(this).text("收起∧")
        } else if ($(this).text() === "收起∧") {
            $(this).next(".open-sibling").hide(500);
            $(this).text("历史记录∨");
        }
    });

    //日期选择器
    jQuery(function ($) {
        $('#selectTime').datepicker({
            inline: true,
            format: "yyyymmdd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        })
            .next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

        var nodeSysId = '${task.nodeSysId}';
        var nodeStatus;
        $.ajax({
            type: "GET",
            url: "/api/nodes/checkNodeIsFinished",
            dataType: "json",
            data: {nodeSysId: nodeSysId},
            success: function (model) {
                console.log(model);
                if (model.code == "200") {
                    if (model.data) {
                        console.log(model.message);
                        //节点已完成
                        nodeStatus = "1";
                        $('#resp-Result').val("督查节点:已完成");
                    } else {
                        console.log(model.message);
                        //节点未完成
                        nodeStatus = "0";
                        $('#resp-Result').val("督查节点:未完成");
                    }
                } else {
                    console.log("数据错误，没有该节点！")
                }
            },
            error: function (model) {
            }
        });

        $(".downloadFile").each(function () {
            if (isEmpty($(this).data("id"))) {
                $(this).attr("style", "display:none;");
            }
        });

    });
</script>
